#include <stdio.h>

void quickSort(int a[], int low, int height)
{
    if (low < height)
    {
        int p = partition(a, low, height);
        quickSort(a, low, p - 1);
        quickSort(a, p + 1, height);
    }
}

int partition(int a[], int low, int height)
{
    int pivot = a[low];
    while (low < height)
    {
        while (low < height && a[height] >= pivot)
        {
            --height;
        }
        a[low] = a[height];
        while (low < height && a[low] <= pivot)
        {
            ++low;
        }
        a[height] = a[low];
    }
    a[low] = pivot;
    return low;
}

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        printf("%d\t", a[i]);
    }
}

int main()
{
    printf("\n\n========================================================================\n\n");

    int a[10] = {6, 98, 56, 32, 1, 20, 3, 45, 14, 9};
    print(a, 10);
    printf("\n");
    quickSort(a, 0, 9);
    print(a, 10);
    printf("\n\n========================================================================\n\n");
}